#pragma once
#include <windows.h>
#include <atlbase.h>

#include "WordProxyExceptions.h"

typedef struct {FLOAT Left; FLOAT Right; FLOAT Top; FLOAT Bottom; } DOCUMENT_MARGINS;
typedef struct {FLOAT Height; FLOAT Width; } DOCUMENT_PAGE_SIZE;


class CWordProxy
{
	CComPtr<IDispatch> m_WordApplication;
	CComPtr<IDispatch> m_Document;
	
	DISPID GetDispID(IDispatch* pIDispatch, const CComBSTR& Name );
	DISPPARAMS CreateDispParams(CComVariant& Param);

	void SetProperty(IDispatch* pIDispatch, const CComBSTR& PropName, const CComVariant& Value);
	void GetProperty(IDispatch* pIDispatch, const CComBSTR& PropName, CComVariant& Value);
	
	void CallMethod(IDispatch* pIDispatch, const CComBSTR& ProcName );
	void CallMethod(IDispatch* pIDispatch, const CComBSTR& ProcName, CComVariant& Result);
	void CallMethod(IDispatch* pIDispatch, const CComBSTR& ProcName, DISPPARAMS* pDispParams);
	void CallMethod(IDispatch* pIDispatch, const CComBSTR& ProcName, DISPPARAMS* pDispParams, CComVariant& Result);
	
	void SetPictureStyle(IDispatch* Picture);
public:
	CWordProxy();
	void Initialize();
	void Finalize(); 

	void NewDocument();
	void PastePicture(LPCTSTR PathToFile);
	void PageBreakAndUP();
	void SaveAs(LPCTSTR PathToFile);

	void GetMarginsInPt(DOCUMENT_MARGINS& Margins);
	void GetPageSizeInPt(DOCUMENT_PAGE_SIZE& PageSize);
	LONG PointsToPixels(FLOAT Pt, bool Vertical);

	void Test();
};